package cn.jhz.learn.blog.service.core.open.photo.impl;

import cn.jhz.learn.blog.component.ValidationHolder;
import cn.jhz.learn.blog.dao.photo.BlogAlbumSubfieldMapper;
import cn.jhz.learn.blog.dao.photo.BlogPhotoSubfieldMapper;
import cn.jhz.learn.blog.po.photo.BlogAlbumSubfield;
import cn.jhz.learn.blog.po.photo.BlogPhotoSubfield;
import cn.jhz.learn.blog.service.core.open.photo.AlbumService;
import cn.jhz.learn.blog.vo.article.query.page.ArticlePageView;

import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("albumService")
public class AlbumServiceImpl implements AlbumService {
    private final BlogAlbumSubfieldMapper albumSubfieldMapper;
    private final BlogPhotoSubfieldMapper photoSubfieldMapper;

    @Autowired
    public AlbumServiceImpl(BlogAlbumSubfieldMapper albumSubfieldMapper, BlogPhotoSubfieldMapper photoSubfieldMapper) {
        this.albumSubfieldMapper = albumSubfieldMapper;
        this.photoSubfieldMapper = photoSubfieldMapper;
    }

//    @Override
//    public List<BlogAlbumSubfield> getSubfields(@NotNull ArticlePageView pageView) {
//        PageHelper.startPage(pageView.getPage_num(), pageView.getPage_size());
//        return albumSubfieldMapper.selectByBlogId(null, pageView.getBlog_id().get());
//    }
//
//    @Override
//    public List<BlogAlbumSubfield> getSubfields(Integer uid, @NotNull ArticlePageView pageView) {
//        PageHelper.startPage(pageView.getPage_num(), pageView.getPage_size());
//        return albumSubfieldMapper.selectByBlogId(ValidationHolder.getOwn(BlogAlbumSubfield.class.getName() + pageView.getSubfield_id()) ? uid : null, pageView.getBlog_id().get());
//    }
//
//    @Override
//    public List<BlogPhotoSubfield> getAlbums(@NotNull ArticlePageView pageView) {
//        PageHelper.startPage(pageView.getPage_num(), pageView.getPage_size());
//
//        return photoSubfieldMapper.selectByBlogIdOrSubfieldId(
//                pageView.getBlog_id().orElse(null), pageView.getSubfield_id().orElse(null), null);
//    }
//
//    @Override
//    public List<BlogPhotoSubfield> getAlbums(Integer uid, @NotNull ArticlePageView pageView) {
//        PageHelper.startPage(pageView.getPage_num(), pageView.getPage_size());
//
//        return photoSubfieldMapper.selectByBlogIdOrSubfieldId(
//                pageView.getBlog_id().orElse(null),
//                pageView.getSubfield_id().orElse(null),
//                ValidationHolder.getOwn(BlogPhotoSubfield.class.getName() + pageView.getSubfield_id()) ? uid : null);
//    }

    @Override
    public BlogPhotoSubfield getAlbum(Integer photo_subfield_id) {
        return (BlogPhotoSubfield) ValidationHolder.getParam(BlogPhotoSubfield.class.getName() + photo_subfield_id);
    }

    @Override
    public List<BlogAlbumSubfield> getSubfields(ArticlePageView pageView) {
        return null;
    }

    @Override
    public List<BlogAlbumSubfield> getSubfields(Integer uid, @NotNull ArticlePageView pageView) {
        return null;
    }

    @Override
    public List<BlogPhotoSubfield> getAlbums(ArticlePageView pageView) {
        return null;
    }

    @Override
    public List<BlogPhotoSubfield> getAlbums(Integer uid, ArticlePageView pageView) {
        return null;
    }

    @Override
    public BlogPhotoSubfield getAlbum(Integer uid, Integer photo_subfield_id) {
        return (BlogPhotoSubfield) ValidationHolder.getParam(BlogPhotoSubfield.class.getName() + photo_subfield_id);
    }

}
